package grape.crm.rest.customercredential.mapper;

import grape.crm.rest.customercredential.form.CustomerCredentialAttrCreateForm;
import grape.crm.service.customercredential.param.AddCustomerCredentialParam;
import grape.crm.service.customercredential.po.CustomerCredential;
import grape.common.rest.mvc.WebMapper;
import org.mapstruct.Mapper;
import grape.crm.rest.customercredential.form.CustomerCredentialCreateForm;
import grape.crm.rest.customercredential.form.CustomerCredentialUpdateForm;
import grape.crm.rest.customercredential.form.CustomerCredentialListPageForm;
import grape.crm.rest.customercredential.vo.CustomerCredentialVo;
import org.mapstruct.ReportingPolicy;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 客户证件表 前端领域模型映射
 * </p>
 *
 * @author yangwei
 * @since 2020-09-14
 */
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CustomerCredentialWebMapper extends WebMapper<CustomerCredentialVo, CustomerCredential> {

    CustomerCredential formToPo(CustomerCredentialCreateForm f);
    CustomerCredential formToPo(CustomerCredentialUpdateForm f);
    CustomerCredential formToPo(CustomerCredentialListPageForm f);
    
    AddCustomerCredentialParam formToParam(CustomerCredentialCreateForm f);
    AddCustomerCredentialParam formToParam(CustomerCredentialAttrCreateForm f);

    default List<AddCustomerCredentialParam> createFormsToParams(List<CustomerCredentialCreateForm> forms) {
        if (forms == null) {
            return null;
        }
        return forms.stream().map(this::formToParam).collect(Collectors.toList());
    }
    default List<AddCustomerCredentialParam> attrCreateFormsToParams(List<CustomerCredentialAttrCreateForm> forms) {
        if (forms == null) {
            return null;
        }
        return forms.stream().map(this::formToParam).collect(Collectors.toList());
    }
}
